from api.models import DomainTopN, NXDomainRate, QPM
from django.db import models
import django_filters


class DomainTopNFilter(django_filters.FilterSet):
    # http://127.0.0.1:8848/api/v1/topn/?datetime_start=2023-04-19T11:00:00Z&datetime_end=2023-04-19T11:00:00Z
    datetime_start = django_filters.DateTimeFilter(field_name="datetime", lookup_expr='gte')
    datetime_end = django_filters.DateTimeFilter(field_name="datetime", lookup_expr='lte')

    class Meta:
        model = DomainTopN
        fields = {
            "rank": ["exact", "lt", "gt", "gte", "lte"],
            # http://127.0.0.1:8848/api/v1/topn/?datetime__gte=2023-04-19T11:00:00Z&datetime__lte=2023-04-19T11:00:00Z
            "datetime": ["exact", "lt", "gt", "gte", "lte", "range"]
        }
